import request from '@/utils/request';

/**
 * 薪资模板配置
 */
// 获取薪资年份列表
export async function querySalaryYearList(organizationCode) {
    return request(`/api/finance/salary/v1/salaryBase/years/${organizationCode}`);
}

// 薪资模板配置-薪资模板页总概(12个月模板数据) -> 王耀辉
export async function querySalaryTemplateMain(organizationCode, year, month) {
    return request(`/api/finance/salary/v1/salaryTemplate/main/${organizationCode}/${year}/${month}`);
}

// 薪资模板配置-薪资构成要素概览(薪资条预览表格) -> 王耀辉
export async function querySalaryOverviewTable(organizationCode, year, month) {
    return request(`/api/finance/salary/v1/salaryTemplate/overview/info/${organizationCode}/${year}/${month}`);
}

// 薪资模板配置-薪资条预览
export async function querySalarySheet(organizationCode, year, month) {
    return request(`/api/finance/salary/v1/salaryTemplate/overview/payroll/info/${organizationCode}/${year}/${month}`);
}

// 薪资模板配置-校验是否需要初始化(批量引入月模板)
export async function queryNeedInit(organizationCode, year) {
    return request(`/api/finance/salary/v1/salaryTemplate/init/check/${organizationCode}/${year}`);
}

// 薪资模板配置 - 指定年份批量引用该组织指定年的月模板配置
export async function batchQuote(organizationCode, fromYear, toYear) {
    return request(`/api/finance/salary/v1/salaryTemplate/init/batchQuote/${organizationCode}/${fromYear}/${toYear}`);
}

// 薪资模板配置-员工基本信息删除
export async function onDeleteStaffItem(id) {
    return request(`/api/finance/salary/v1/salaryTemplate/baseItem/delete/${id}`);
}

// 薪资模板配置-员工基础信息模板获取
export async function queryStaffBaseItemList(organizationCode, year) {
    return request(`/api/finance/salary/v1/salaryTemplate/baseItem/info/${organizationCode}/${year}`);
}

// 薪资模板配置-员工基础信息模板编辑获取
export async function queryStaffEditBaseItemList(organizationCode, year) {
    return request(`/api/finance/salary/v1/salaryTemplate/baseItem/edit/${organizationCode}/${year}`);
}

// 薪资模板配置-获取编辑月模板视图数据
export async function querySalaryMonthItemData(organizationCode, year, month) {
    return request(`/api/finance/salary/v1/salaryTemplate/edit/${organizationCode}/${year}/${month}`);
}

// 薪资模板配置-编辑员工基本信息列表
export async function onEditStaffBaseInfoList(params) {
    return request('/api/finance/salary/v1/salaryTemplate/baseItem/save', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

// 薪资模板配置-编辑月份模板
export async function onEditMonthTemplate(params) {
    return request('/api/finance/salary/v1/salaryTemplate/salaryItem/save', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

// 薪资模板配置-是否展示引导页
export async function queryShowGuide(organizationCode) {
    return request(`/api/finance/salary/v1/salaryTemplate/user/browseHistory/show/${organizationCode}`);
}

// 薪资模板配置-完成新手引导
export async function onFinishGuide(organizationCode) {
    return request(`/api/finance/salary/v1/salaryTemplate/user/browseHistory/finish/${organizationCode}`);
}

/**
 * 模板库
 */
// 模板库-获取公司列表
export async function queryCompanyList(organizationCode) {
    return request(`/api/finance/salary/v1/org/company/list/${organizationCode}`);
}

// 模板库-获取模板库年份
export async function querySalaryLibYearList(orgCode) {
    return request(`/api/finance/salary/v1/salaryTemplate/lib/years/${orgCode}`);
}

// 模板库-获取模板库
export async function queryCompanyTemplateList(fromOrgCode, organizationCode, year) {
    return request(`/api/finance/salary/v1/salaryTemplate/lib/${fromOrgCode}/${organizationCode}/${year}`);
}

// 模板库-模板引用
export async function onUseTemplate({ fromTemplateId, fromOrgCode, toTemplateId, toOrgCode }) {
    return request(
        `/api/finance/salary/v1/salaryTemplate/salaryItem/quote/${fromTemplateId}/${fromOrgCode}/${toTemplateId}/${toOrgCode}`
    );
}

// 模板库-模板批量引用
export async function onUseMultipleTemplate({ fromOrgCode, toOrgCode, fromTemplateIds, toYear }) {
    return request(
        `/api/finance/salary/v1/salaryTemplate/salaryItem/batchQuote/${fromOrgCode}/${toYear}/${toOrgCode}/${fromTemplateIds}`
    );
}

// 薪资条生成时间保存 -> 王耀辉
export async function generateDateSave({ id, generateDate }) {
    return request('/api/finance/salary/v1/salaryTemplate/generateDate/save', {
        method: 'POST',
        data: {
            id,
            generateDate
        }
    });
}

// 薪资模板进入下一步的校验 -> 王耀辉
export async function validateSalaryTemplateBeforeNext(organizationCode, year) {
    return request(`/api/finance/salary/v1/salaryTemplate/nextCheck/${organizationCode}/${year}`, {
        method: 'GET'
    });
}

// 重置
export async function reset(organizationCode, year) {
    return request(`/api/finance/salary/v1/salaryTemplate/reset/${organizationCode}/${year}`);
}

// 薪资单打印概览 -> 卢俊杰
export async function payrollPrint({ organizationCode, year, month }) {
    return request(
        `/api/finance/salary/v1/salaryTemplate/overview/payrollPrint/info/${organizationCode}/${year}/${month}`
    );
}

// 薪资条预览-员工信息打印设置 -> 卢俊杰
export async function saveStaffPrint(params) {
    return request('/api/finance/salary/v1/salaryTemplate/staffPrint/save', {
        method: 'POST',
        data: params
    });
}

// 删除月模板中的薪资要素
export async function deleteSalaryItem({ templateId, salaryItemId }) {
    return request(`/api/finance/salary/v1/salaryTemplate/salaryItem/delete/${templateId}/${salaryItemId}`, {
        method: 'GET'
    });
}

// 特殊社置-假种类型 list
export async function attendType(organizationCode) {
    return request(`/api/finance/salary/v1/salarySet/param/attendType/${organizationCode}`, {
        method: 'GET'
    });
}

/**
 * 构成要素配置
 */
// 构成要素配置-员工基础信息列表/薪资加减项列表
export async function querySalaryItemList(organizationCode, itemType) {
    return request(`/api/finance/salary/v1/salaryItem/query/${organizationCode}/${itemType}`);
}

// 构成要素配置-数字字典 map
export async function queryDictMap(confTypes) {
    return request(`/api/finance/salary/v1/dict/query/map/${confTypes}`);
}
// 构成要素配置-数字字典 list
export async function queryDictList(confTypes) {
    return request(`/api/finance/salary/v1/dict/query/list/${confTypes}`);
}

// 流程取值字典 -> 王耀辉
export async function queryFlowTypeList({ organizationCode, itemType }) {
    return request(`/api/finance/salary/v1/salaryItem/flowType/list/${organizationCode}/${itemType}`);
}
// 条件取值映射关系 -> 王耀辉
export async function queryConditionList(organizationCode) {
    return request(`/api/finance/salary/v1/salaryItem/conditionSelect/list/${organizationCode}`);
}

// 构成要素配置-获取上级薪资项列表
export async function queryParentSalaryItemList(organizationCode, itemType) {
    return request(`/api/finance/salary/v1/salaryItem/query/parent/${organizationCode}/${itemType}`);
}

// 构成要素配置-新增员工信息，取值关联字段下拉
export async function queryStaffRelativeKeyList(organizationCode, type) {
    return request(`/api/finance/salary/v1/salaryItem/staffInfo/query/${organizationCode}/${type}`);
}

// 构成要素配置-薪资项启用/暂停(一级)
export async function onChangeSalaryItemStatusFirst(id, status) {
    return request(`/api/finance/salary/v1/salaryItem/enable/first/${id}/${status}`);
}

// 构成要素配置-薪资项启用/暂停(二级)
export async function onChangeSalaryItemStatusSecond(id, status) {
    return request(`/api/finance/salary/v1/salaryItem/enable/second/${id}/${status}`);
}

// 构成要素配置-删除薪资项
export async function onDeleteSalaryItem(id) {
    return request(`/api/finance/salary/v1/salaryItem/delete/${id}`);
}

// 构成要素配置-新增员工信息
export async function onAddStaffInfo(params) {
    return request('/api/finance/salary/v1/salaryItem/staff/save', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

// 构成要素配置-新增薪资构成要素
export async function onAddSalaryItem(params) {
    return request('/api/finance/salary/v1/salaryItem/save', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

// 构成要素配置-编辑薪资构成要素
export async function onEditSalaryItemSimple(params) {
    return request('/api/finance/salary/v1/salaryItem/edit/simple', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

export async function onEditSalaryItemFirst(params) {
    return request('/api/finance/salary/v1/salaryItem/edit/first', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

export async function onEditSalaryItemSecond(params) {
    return request('/api/finance/salary/v1/salaryItem/edit/second', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

// 构成要素配置-公式器映射表
export async function queryMapping() {
    return request('/api/finance/salary/v1/salaryItem/conditionSelect/mapping');
}

// 构成要素配置-薪资构成要素详情
export async function querySalaryItemInfo(id) {
    return request(`/api/finance/salary/v1/salaryItem/info/${id}`, { method: 'POST' });
}

/**
 * 参数设置
 */
// 参数设置-获取薪资发放参数信息
export async function queryParameterInfo(organizationCode) {
    return request(`/api/finance/salary/v1/salarySet/grant/info/${organizationCode}`);
}

// 参数设置-组织岗位列表
export async function queryJobsList(params) {
    return request('/api/finance/salary/v1/org/post/list', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

// 参数设置-薪资发放设置保存
export async function onSalarySetReset(organizationCode) {
    return request(`/api/finance/salary/v1/salarySet/grant/reset/${organizationCode}`, {
        method: 'GET'
    });
}

// 参数设置-薪资发放设置下一步数据获取
export async function onSalaryPaySettingNext(params) {
    return request('/api/finance/salary/v1/salarySet/grant/next', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

// 参数设置-查询社平工资设置
export async function socialWageQuery(organizationCode, year) {
    return request(`/api/finance/salary/v1/salarySet/socialWage/query/${year}/${organizationCode}`, {
        method: 'POST'
    });
}

// 参数设置-更新社平工资设置
export async function socialWageUpdate(data) {
    return request('/api/finance/salary/v1/salarySet/socialWage/update', {
        method: 'POST',
        data
    });
}

// 参数设置-薪资发放设置保存
export async function onSaveParameterSetting(params) {
    return request('/api/finance/salary/v1/salarySet/grant/save', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

// 参数设置-保存标准工时设置
export async function onSaveWorkingTimeSetting(params) {
    return request('/api/finance/salary/v1/salarySet/workHours/save', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

// 参数设置-获取标准工时设置通用信息
export async function queryWorkingTimeCommonInfo(year) {
    return request(`/api/finance/salary/v1/salarySet/workHours/common/info/${year}`);
}

// 参数设置-获取标准工时12月份信息
export async function queryWorkingTimeMonthInfo(year) {
    return request(`/api/finance/salary/v1/salarySet/workHours/resign/info/${year}`);
}

// 参数设置-获取所有信息
export async function queryWorkingInfo(organizationCode, year) {
    return request(`/api/finance/salary/v1/salarySet/workHours/info/${organizationCode}/${year}`);
}

// 参数设置-当月入离职人员工作日设置信息
export async function queryWorkingCalculate(year, type) {
    return request(`/api/finance/salary/v1/salarySet/workHours/calculate/${year}/${type}`);
}

// 参数设置-获取定时器与提醒设置信息
export async function queryRemindInfo() {
    return request('/api/finance/salary/v1/salarySet/generate/info');
}

// 参数设置-保存定时器与提醒设置
export async function onSaveRemindSetting(params) {
    return request('/api/finance/salary/v1/salarySet/generate/save', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

// 参数设置-获取基础配置信息
export async function queryBaseSettingInfo(organizationCode) {
    return request(`/api/finance/salary/v1/salarySet/param/info/${organizationCode}`);
}

// 参数设置-保存基础信息
export async function onSaveBaseSetting(params) {
    return request('/api/finance/salary/v1/salarySet/param/save', {
        method: 'POST',
        data: {
            ...params
        }
    });
}

// 参数设置-获取基础配置信息
export async function querySpecialSettingInfo(organizationCode) {
    return request(`/api/finance/salary/v1/salarySet/param/special/info/${organizationCode}`);
}

// 参数设置-保存基础信息
export async function onSaveSpecialSetting(params) {
    return request('/api/finance/salary/v1/salarySet/param/special/save', {
        method: 'POST',
        data: params
    });
}

/**
 * 绩效系数
 */
// 绩效系数 导入
export async function queryBaseKpi(postData) {
    return request('/api/finance/salary/v1/salaryBaseKpi/queryByPage', {
        method: 'POST',
        data: postData
    });
}

// 个税初始化分页列表 -> 雄伟
export async function queryTaxInitByPage(postData) {
    return request('/api/finance/salary/v1/salaryPayrollTax/queryTaxInitByPage', {
        method: 'POST',
        data: {
            page: { ...postData.page },
            employeeCode: postData.employeeCode,
            organizationCode: postData.organizationCode
        }
    });
}

// 专项扣款 - >员工最新导入的计薪年月份
export async function querySpecialTaxYearMonth(organizationCode) {
    return request(`/api/finance/salary/v1/salaryPayrollSpecialTax/getLastImportYearMonth/${organizationCode}`, {
        method: 'GET'
    });
}

// 专项扣款 - > 获取列表：建明
export async function querySpecialTaxList(postData) {
    return request('/api/finance/salary/v1/salaryPayrollSpecialTax/salaryPayrollSpecialTaxVOList', {
        method: 'POST',
        data: postData
    });
}

// 专项扣款 - >下载：建明
export async function downloadSpecialTax() {
    return request('/api/finance/salary/v1/template/excels/specialTaxTemplate.xlsx', {
        method: 'GET',
        getResponse: true,
        encryption: false,
        isFile: true,
        responseType: 'blob',
        headers: { 'Content-Type': 'application/json' }
    });
}

// 专项扣款 -> 通过ID获取：建明
export async function getSpecialTaxById(postData) {
    return request(`/api/finance/salary/v1/salaryPayrollSpecialTax/querySpecialTaxById/${postData.id}`, {
        method: 'GET'
    });
}

// 专项扣款 -> 更新 ：建明
export async function updateSpecialTax(postData) {
    return request('/api/finance/salary/v1/salaryPayrollSpecialTax/updateSalaryPayrollSpecialTaxInfoById', {
        method: 'POST',
        data: postData
    });
}

// 专项扣款 -> 删除 ：建明
export async function deleteSpecialTax(postData) {
    return request(`/api/finance/salary/v1/salaryPayrollSpecialTax/deleteSpecialTaxById/${postData.id}`, {
        method: 'GET'
    });
}

// 绩效系数导入 - >员工绩效最新导入的计薪年月份
export async function queryBaseKpiLastImportYearMonth(organizationCode) {
    return request(`/api/finance/salary/v1/import/lastImportYearMonth/kpi/${organizationCode}`, {
        method: 'GET'
    });
}

// 绩效系数导入 - >员工绩效最新导入的计薪年月份
export async function baseKpiDownload() {
    return request('/api/finance/salary/v1/template/excels/kpiTemplate.xlsx', {
        method: 'GET',
        getResponse: true,
        encryption: false,
        isFile: true,
        responseType: 'blob',
        headers: { 'Content-Type': 'application/json' }
    });
}

// 绩效系数导入 -> 通过ID获取绩效系数 ：雄伟
export async function getBaseKpi(postData) {
    return request(`/api/finance/salary/v1/salaryBaseKpi/get/${postData.id}`, {
        method: 'GET'
    });
}

// 绩效系数导入 -> 更新绩效系数 ：雄伟
export async function updateBaseKpi(postData) {
    return request('/api/finance/salary/v1/salaryBaseKpi/update', {
        method: 'POST',
        data: postData
    });
}

// 绩效系数导入 -> 删除绩效系数 ：雄伟
export async function deleteSalaryBaseKpi(postData) {
    return request(`/api/finance/salary/v1/salaryBaseKpi/del/${postData.id}`, {
        method: 'GET'
    });
}

// 获取个税初始化能否导入标识 ：雄伟
export async function getSalaryPayrollTaxStatus(organizationCode) {
    return request(`/api/finance/salary/v1/salaryPayrollTax/getStatus/${organizationCode}`, {
        method: 'GET'
    });
}

// 个税初始化 -> 下载 ：雄伟
export async function salaryPayrollTaxDownload() {
    return request('/api/finance/salary/v1/template/excels/taxTemplate.xlsx', {
        method: 'GET',
        getResponse: true,
        encryption: false,
        isFile: true,
        responseType: 'blob',
        headers: { 'Content-Type': 'application/json' }
    });
}

// 个税初始化 -> 删除个税初始化 ：雄伟
export async function deleteSalaryPayrollTax(postData) {
    return request(`/api/finance/salary/v1/salaryPayrollTax/delTaxInit/${postData.id}`, {
        method: 'GET'
    });
}

// 个税初始化 -> 通过ID获取个税初始化数据 ：雄伟
export async function getSalaryPayrollTax(postData) {
    return request(`/api/finance/salary/v1/salaryPayrollTax/getTaxInit/${postData.id}`, {
        method: 'GET'
    });
}

// 个税初始化 -> 更新个税初始化信息 ：雄伟
export async function updateSalaryPayrollTax(postData) {
    return request('/api/finance/salary/v1/salaryPayrollTax/updateTaxInit', {
        method: 'POST',
        data: postData
    });
}

export async function getKpiSalaryItems(organizationCode) {
    return request(`/api/finance/salary/v1/import/getKpiSalaryItems/${organizationCode}`, {
        method: 'GET'
    });
}

// 险金 导入
export async function queryPayrollSocial(postData) {
    return request(`/api/finance/salary/v1/salaryPayrollSocial/queryByPage/${postData.year}/${postData.month}`, {
        method: 'POST',
        data: {
            page: { ...postData.page }
        }
    });
}

// 绩效系数导入 - >员工绩效最新导入的计薪年月份
export async function queryPayrollSocialLastImportYearMonth() {
    return request('/api/finance/salary/v1/import/lastImportYearMonth/social', {
        method: 'GET'
    });
}

export async function queryPayrollTax(postData) {
    return request(`/api/finance/salary/v1/salaryPayrollTax/queryByPage/${postData.year}/${postData.month}`, {
        method: 'POST',
        data: {
            page: { ...postData.page }
        }
    });
}

// 薪资复核--查询薪资未查看列表
export async function querySalaryUnView(postData) {
    return request('/api/finance/salary/recheck/querySalaryUnView', {
        method: 'POST',
        data: postData
    });
}

// 薪资复核--查询员工确认人数等
export async function refreshFloatData(postData) {
    return request('/api/finance/salary/recheck/refreshFloatData', {
        method: 'POST',
        data: postData
    });
}

// 险金基数初始化
const premiumBaseService = {
    // 删除
    async deleteSocial(postData) {
        return request(`/api/finance/salary/v1/social/init/delete/${postData.id}`, {
            method: 'GET'
        });
    },
    // 险金基数初始化取消操作
    async doCancelSocial(organizationCode) {
        return request(`/api/finance/salary/v1/social/init/doCancel/${organizationCode}`, {
            method: 'GET'
        });
    },
    // 险金基数初始化完成操作
    async doCompleteSocial(organizationCode) {
        return request(`/api/finance/salary/v1/social/init/doComplete/${organizationCode}`, {
            method: 'GET'
        });
    },
    // 通过ID获取险金基数初始化数据
    async getSocial(postData) {
        return request(`/api/finance/salary/v1/social/init/get/${postData.id}`, {
            method: 'GET'
        });
    },
    // 获取险金基数导入数量
    async getImportCountSocial() {
        return request('/api/finance/salary/v1/social/init/getImportCount', {
            method: 'GET'
        });
    },
    // 获取险金基数初始化状态
    async getStatusSocial(organizationCode) {
        return request(`/api/finance/salary/v1/social/init/getStatus/${organizationCode}`, {
            method: 'GET'
        });
    },
    // 导入
    async importSocial() {
        return request('/api/finance/salary/v1/social/init/import', {
            method: 'POST'
        });
    },
    // 险金基数初始化分页列表
    async querySocial(postData) {
        return request('/api/finance/salary/v1/social/init/query', {
            method: 'POST',
            data: postData
        });
    },
    // 更新险金基数初始化信息
    async updateSocial(postData) {
        return request('/api/finance/salary/v1/social/init/update', {
            method: 'POST',
            data: postData
        });
    },
    // 险金基数初始化下载
    async socialDownload() {
        return request('/api/finance/salary/v1/template/excels/socialInitTemplate.xlsx', {
            method: 'GET',
            getResponse: true,
            encryption: false,
            isFile: true,
            responseType: 'blob',
            headers: { 'Content-Type': 'application/json' }
        });
    }
};

const logService = {
    // 查询更改类型
    async queryOperateType({ busiUnit }) {
        return request(`/api/finance/salary/v1/log/logOperateType/${busiUnit}`, {
            method: 'GET'
        });
    },
    // 查询更改内容
    async queryBusiUnitDetail({ busiUnit }) {
        return request(`/api/finance/salary/v1/log/logBusiUnitDetail/${busiUnit}`, {
            method: 'GET'
        });
    },
    /** 薪资模板-操作日志查询 */
    async querySysOperateLog(postData) {
        return request('/api/finance/salary/v1/log/querySysOperateLog', {
            method: 'POST',
            data: postData
        });
    }
};

/**
 * 薪资复核
 */
const salaryRecheck = {
    // 薪资复核 -> 申请付款
    async applyPayment(postData) {
        return request('/api/finance/salary/recheck/applyPay', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> 百分比查询字段获取
    async getLastSysOperationSearchInfo(postData) {
        return request('/api/finance/salary/recheck/getLastSysOperationSearchInfo', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 ->提交审批流 -- 数据存入oa
    async saveApproveBusinessData(data) {
        return request('/api/oa/workflow/finance/salaryCheck/v1/saveApproveBusinessData', {
            method: 'POST',
            data
        });
    },

    // 薪资复核 ->提交审批流
    async approveSubmit(postData) {
        return request(`/api/finance/salary/recheck/approveSubmit/${postData.year}/${postData.month}`, {
            method: 'POST'
        });
    },

    // 薪资复核 -> 获取细项复核
    async getSalaryPayrollItems(salaryPayrollId) {
        return request(`/api/finance/salary/recheck/getSalaryPayrollItems/${salaryPayrollId}`, {
            method: 'GET'
        });
    },

    // 薪资复核 -> 提醒细项复核
    async queryItemCheckWarn(postData) {
        return request('/api/finance/salary/recheck/itemCheckWarn', {
            method: 'POST',
            data: postData.salaryPayrollIdList
        });
    },

    // 最新薪资条的年月份
    async latestSalaryYearMonth(postData) {
        return request('/api/finance/salary/recheck/latestSalaryYearMonth', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> 复核步骤
    async getRecheckSteps(postData) {
        return request('/api/finance/salary/recheck/progressbar', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> 表格数据查询
    async queryTableBodyData(postData) {
        const requestData = {
            ...postData,
            ...postData.searchModel
        };
        delete requestData.searchModel;

        return request('/api/finance/salary/recheck/querySalaryPayroll', {
            method: 'POST',
            data: requestData
        });
    },

    // 薪资发放 -> 表格数据查询
    async queryGrantTableBodyData(postData) {
        const requestData = {
            ...postData,
            ...postData.searchModel
        };
        delete requestData.searchModel;

        return request('/api/finance/salary/grant/querySalaryPayroll', {
            method: 'POST',
            data: requestData
        });
    },

    // 薪资复核 -> 获取下发薪资单设置的时间
    async queryIndependentInformation(postData) {
        return request('/api/finance/salary/recheck/queryIndependentInformation', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> 下发薪资单
    async sendSalaryPayroll(postData) {
        return request('/api/finance/salary/recheck/sendSalaryPayroll', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> 一键提醒
    async oneClickReminder(postData) {
        return request('/api/finance/salary/recheck/oneClickReminder', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 ->表头数据查询
    async queryTableHeadData(postData) {
        return request('/api/finance/salary/recheck/tableHeaderItem', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资发放 ->表头数据查询
    async queryGrantTableHeadData(postData) {
        return request('/api/finance/salary/grant/tableHeaderItem', {
            method: 'POST',
            data: postData
        });
    },

    // 细项复核--获取一级薪资项列表
    async getItemMenus() {
        return request('/api/finance/salary/itemRecheck/getFirstLevelSalaryItems', {
            method: 'GET'
        });
    },

    // 薪资复核--Excel导出
    async excelExport(postData) {
        return request('/api/finance/salary/v1/excel/export/payrollExport', {
            method: 'POST',
            getResponse: true,
            encryption: false,
            isFile: true,
            responseType: 'blob',
            headers: { 'Content-Type': 'application/json' },
            data: postData
        });
    }
};

/**
 * 复核总览
 */
const hrOverviewRecheck = {
    // 薪资复核 -> HR复核 -> 总览 -> 列表查询
    async queryTableBodyData(postData) {
        return request('/api/finance/salary/overviewRecheck/querySalaryPayrollOverview', {
            method: 'POST',
            data: postData
        });
    },
    async queryPayrollTableBodyData(postData) {
        return request('/api/finance/salary/grant/querySalaryPayrollOverview', {
            method: 'POST',
            data: postData
        });
    },
    // 薪资复核 -> HR复核 -> 总览 -> 操作按钮列表获取
    async getCheckButtons(postData) {
        return request('/api/finance/salary/overviewRecheck/get/overviewRecheckButtons', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> HR复核 -> 总览 -> 复审通过
    async passCheck(postData) {
        return request('/api/finance/salary/overviewRecheck/overviewRecheckPass', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> HR复核 -> 总览 -> 终审通过
    async finalPassCheck(postData) {
        return request('/api/finance/salary/overviewRecheck/overviewFinalCheckPass', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> HR复核 -> 总览 -> 复审驳回
    async rejectCheck(postData) {
        return request('/api/finance/salary/overviewRecheck/overviewRecheckReject', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> HR复核 -> 总览 -> 终审驳回
    async finalRejectCheck(postData) {
        return request('/api/finance/salary/overviewRecheck/overviewFinalcheck', {
            method: 'POST',
            data: postData
        });
    },
    /** 薪资复核-操作日志查询 */
    async querySalaryRecheckLog(postData) {
        return request('/api/finance/salary/financeRecheck/querySalaryPayrollOperateLog', {
            method: 'POST',
            data: postData
        });
    },

    /** 查询薪资复核操作人列表 */
    async querySalaryOperateEmployeeList(postData) {
        return request(
            `/api/finance/salary/financeRecheck/querySalaryOperateEmployeeList/${postData.organizationCode}`,
            {
                method: 'GET'
            }
        );
    },

    /** 薪资复核-操作日志枚举 */
    async querySalaryRecheckLogEnum() {
        return request('/api/finance/salary/financeRecheck/getComboBoxQueryCondition', {
            method: 'POST'
        });
    },
    /** 薪资复核-数据详情-查询图表类型集合 */
    async querySalaryRecheckDataChartType(postData) {
        return request('/api/finance/salary/dataDetail/getSalaryRecheckDiagramTypeList', {
            method: 'POST',
            data: postData
        });
    },
    /** 薪资复核-数据详情-通过图表类型查询数据详情 */
    async querySalaryRecheckDataChartTypeList(postData) {
        return request('/api/finance/salary/dataDetail/querySalaryPayrollDataDetailByDiagramType', {
            method: 'POST',
            data: postData
        });
    },
    /** 薪资复核--薪资审批顶部基础信息 */
    async getApproveHeadInfo(postData) {
        return request('/api/finance/salary/recheck/getApproveHeadInfo', {
            method: 'POST',
            data: postData
        });
    }
};

/**
 * HR复核
 */
const hrRecheck = {
    // 薪资复核 -> HR复核 -> 取消复核
    async cancelCheck(postData) {
        return request('/api/finance/salary/hrRecheck/cancelHrCheck', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> HR复核-> 操作按钮列表获取
    async getCheckButtons(postData) {
        return request('/api/finance/salary/hrRecheck/getHrCheckButtons', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> HR复核-> 驳回
    async reject(postData) {
        return request('/api/finance/salary/hrRecheck/hrReject', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> HR复核 -> 复核通过
    async passCheck(postData) {
        return request('/api/finance/salary/hrRecheck/passHrCheck', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> HR复核 -> 批量复核通过
    async passCheckBatch(postData) {
        return request('/api/finance/salary/hrRecheck/passHrCheckBatch', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> HR复核 -> 更新数据
    async updateData(postData) {
        return request('/api/finance/salary/hrRecheck/recaculateSalaryPayroll', {
            method: 'POST',
            data: postData
        });
    }
};

// 通过id获取审批内容
export async function getPostApplyData(id) {
    return request(`/api/oa/workflow/business/v1/${id}/getBusinessData`);
}

// 通过id获取审批内容
export async function querySalaryPayrollProcessRecordById(id) {
    return request(`/api/oa/workflow/finance/salaryCheck/v1/querySalaryPayrollProcessRecordById/${id}`);
}

/**
 * 财务复核
 */
const financialRecheck = {
    // 薪资复核 -> 财务复核 -> 取消复核
    async cancelCheck(postData) {
        return request('/api/finance/salary/financeRecheck/cancelFinanceCheck', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> 财务复核-> 操作按钮列表获取
    async getCheckButtons(postData) {
        return request('/api/finance/salary/financeRecheck/getFinanceCheckButtons', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> 财务复核-> 驳回
    async reject(postData) {
        return request('/api/finance/salary/financeRecheck/financeReject', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> 财务复核-> 批量驳回
    async batchReject(postData) {
        return request('/api/finance/salary/financeRecheck/financeBatchReject', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> 财务复核 -> 复核通过
    async passCheck(postData) {
        return request('/api/finance/salary/financeRecheck/passFinanceCheck', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> 财务复核 -> 批量复核通过
    async passCheckBatch(postData) {
        return request('/api/finance/salary/financeRecheck/passFinanceCheckBatch', {
            method: 'POST',
            data: postData
        });
    },

    // 薪资复核 -> 财务复核 -> 更新数据
    async updateData(postData) {
        return request('/api/finance/salary/financeRecheck/recaculateSalaryPayroll', {
            method: 'POST',
            data: postData
        });
    }
};

// 薪资复核 -> HR复核 -> 推迟下月发放
export async function postponeNextMonth(postData) {
    return request('/api/finance/salary/recheck/postponeNextMonth', {
        method: 'POST',
        data: postData
    });
}

// 复核 -> 驳回标签信息
export async function queryPayrollTableToolMsg(postData) {
    return request('/api/finance/salary/recheck/queryPayrollTableToolMsg', {
        method: 'POST',
        data: postData
    });
}

/**
 * 绩效薪资复核
 * @type {{getCheckButtons(*): Promise<unknown>}}
 */
const itemRecheckService = {
    async latestSalaryYearMonth() {
        return request('/api/finance/salary/recheck/latestSalaryYearMonth', {
            method: 'GET'
        });
    },

    // 操作按钮列表获取
    async getCheckButtons(postData) {
        return request(
            `/api/finance/salary/itemRecheck/getItemCheckButtons/${postData.year}/${postData.month}/${postData.rootSalaryItemId}`,
            {
                method: 'GET'
            }
        );
    },

    async queryTableHeadData(postData) {
        return request('/api/finance/salary/itemRecheck/getItemDetailShowTableHeaderItems', {
            method: 'POST',
            data: postData
        });
    },

    async queryTableBodyData(postData) {
        const requestData = {
            ...postData,
            ...postData.searchModel
        };
        delete requestData.searchModel;

        return request('/api/finance/salary/itemRecheck/getTableRecords', {
            method: 'POST',
            data: requestData
        });
    },

    async passCheckBatch(postData) {
        return request('/api/finance/salary/itemRecheck/batchPassItemCheck', {
            method: 'POST',
            data: postData
        });
    },

    async cancelCheckBatch(postData) {
        return request('/api/finance/salary/itemRecheck/batchCancelItemCheck', {
            method: 'POST',
            data: postData
        });
    },

    async cancelCheck(postData) {
        return request('/api/finance/salary/itemRecheck/cancelItemCheck', {
            method: 'POST',
            data: postData
        });
    },

    async passCheck(postData) {
        return request('/api/finance/salary/itemRecheck/passItemCheck', {
            method: 'POST',
            data: postData
        });
    },

    async excelExport(postData) {
        const user = localStorage.getItem('user');
        const useObj = user ? JSON.parse(user) : {};

        return request('/api/finance/salary/v1/excel/export/itemRecheck', {
            method: 'POST',
            getResponse: true,
            encryption: false,
            isFile: true,
            responseType: 'blob',
            headers: {
                'Content-Type': 'application/json',
                current_account_user_code: useObj.userCode
            },
            data: postData
        });
    }
};

const payoffService = {
    // 薪资发放--操作按钮列表获取
    async queryButtons(postData) {
        return request(`/api/finance/salary/grant/getTableToolButtons/${postData.year}/${postData.month}`, {
            method: 'GET'
        });
    },

    // 薪资发放--获取表头配置
    async queryTableHeadData(postData) {
        return request(`/api/finance/salary/grant/getTableHeaderItems/${postData.year}/${postData.month}`, {
            method: 'GET'
        });
    },

    // 薪资发放--获取表单数据
    async queryTableBodyData(postData) {
        const requestData = {
            ...postData,
            ...postData.searchModel
        };
        delete requestData.searchModel;
        delete requestData.year;
        delete requestData.month;

        return request(
            `/api/finance/salary/grant/getTableRecords/${postData.year}/${postData.month}/${postData.organizationCode}`,
            {
                method: 'POST',
                data: requestData
            }
        );
    },

    async getPayoffState(postData) {
        return request('/api/salary/calculate/salarypayoff/excelexport/getPayoffState', {
            method: 'POST',
            data: postData
        });
    },

    async getExportInfo(postData) {
        return request(
            `/api/finance/salary/grant/getExportInfo/${postData.year}/${postData.month}/${postData.organizationCode}`,
            {
                method: 'GET',
                data: postData
            }
        );
    },

    /** 执行付款 */
    async doPayoff(postData) {
        return request(
            `/api/finance/salary/grant/executePay/${postData.year}/${postData.month}/${postData.organizationCode}`,
            {
                method: 'POST',
                data: postData
            }
        );
    },

    /** 操作按钮获取 */
    async getTableToolButtons(postData) {
        return request(
            `/api/finance/salary/grant/getTableToolButtons/${postData.year}/${postData.month}/${postData.organizationCode}`,
            {
                method: 'GET'
            }
        );
    },

    async exportFile(postData) {
        return request('/api/finance/salary/v1/excel/export/grantExport', {
            method: 'POST',
            getResponse: true,
            encryption: false,
            isFile: true,
            responseType: 'blob',
            headers: { 'Content-Type': 'application/json' },
            data: postData
        });
    }
};

export {
    logService,
    salaryRecheck,
    hrRecheck,
    financialRecheck,
    itemRecheckService,
    payoffService,
    hrOverviewRecheck,
    premiumBaseService
};
